package com.zyb.insurance.policy.listener;

import com.zyb.insurance.policy.infrastructure.ElasticsearchManager;
import com.zyb.insurance.policy.infrastructure.HBaseManager;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class SystemBootstrapListener implements ServletContextListener {

    @Autowired
    private HBaseManager hBaseManager;
    @Autowired
    private ElasticsearchManager elasticsearchManager;

    public void contextInitialized(ServletContextEvent servletContextEvent) {
        hBaseManager.createInsurancePolicyTableIfNotExists();
        elasticsearchManager.createInsurancePolicyIndexIfNotExits();
    }

    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }

}
